import React from "react";
import { BrowserRouter, useRoutes } from "react-router-dom";
const Home = React.lazy(() => import("../views/home"));
const Detail = React.lazy(() => import("../views/detail"));
const Login = React.lazy(() => import("../views/login"));
const My = React.lazy(() => import("../views/my"));

const routes = [
  {
    path: "/",
    element: <Home></Home>,
  },
  {
    path: "/detail/:id",
    element: <Detail></Detail>,
  },
  {
    path: "/login",
    element: <Login></Login>,
  },
  {
    path: "/my",
    element: <My></My>,
  },
];

const Router = () => {
  const App = () => useRoutes(routes);
  return (
    <BrowserRouter>
      <App></App>
    </BrowserRouter>
  );
};

export default Router;
